package interfaceDemo;

import java.util.Arrays;
import java.util.Comparator;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2023-04-05
 * Time: 16:59
 */
class AgeComapre implements Comparator<Teacher> {
    @Override
    public int compare(Teacher o1, Teacher o2) {
        return o2.age - o1.age;
    }
}
public class Main {
    public static void main(String[] args) throws CloneNotSupportedException {
//        Person person1 = new Student();
//        person1.eat();
//        person1.run();
////        System.out.println(Person.a);
//        Person person2 = new Teacher();
//        person2.eat();
//        person2.run();
//        System.out.println( person2.getClass().getName() );
       //比较的第一种写法
        Student student1 = new Student("王五", 30);
        Student student2 = new Student("张三", 10);
        Student []students = {student1,student2};
//        Arrays.sort(students);
//        System.out.println(Arrays.toString(students));

        //比较器的写法
//        Teacher teacher1 = new Teacher("张老师",30);
//        Teacher teacher2 = new Teacher("王老师",25);
//        Teacher teacher3 = new Teacher("陈老师",20);
//        Teacher [] teachers = {teacher1,teacher2,teacher3};
//        AgeComapre ageComapre = new AgeComapre();
//        Arrays.sort(teachers, ageComapre);
//        System.out.println(Arrays.toString( teachers));

        //克隆接口的使用
        student1.m.money = 100;
        Student s2 = (Student) student1.clone();
//        System.out.println(s2);
        s2.name = "老六";
        s2.m.money = 15.5;
        System.out.println(student1);
        System.out.println(s2);
    }
}
